package com.vanEngine.tests
{
	import avmplus.FLASH10_FLAGS;
	
	import flash.display.Sprite;
	import flash.utils.Dictionary;
	import flash.utils.getQualifiedClassName;
	
	import com.vanEngine.util.VHashMap;

	public class VHashMapTester extends Sprite
	{
		public function VHashMapTester()
		{
			var hashMap:VHashMap = new VHashMap();
			
			hashMap["key"] = "value"
			
			trace( "中括号赋值,取值:", hashMap["key"] == "value" );
			
			hashMap.put( "key", "value2" );
			
			trace( "put()赋值,中括号取值:", hashMap["key"] == "value2" );
			
			trace( "get()取值:", hashMap.get( "key" ) == "value2" );
			
			hashMap.put( "2", 2 );
			
			hashMap.put( 2, 3 );
			
			trace( "是否字符串与整型等值数值是否为相同的Key:",  hashMap[2] == hashMap["2"] );
			
			var sprite1:Sprite = new Sprite();
			
			var sprite2:Sprite = new Sprite();
			
			hashMap[sprite1] = "sprite1";
			
			hashMap[sprite2] = "sprite2";
			
			trace( "使用中括号赋值与取值,是否支持非字符串作为键值:",  hashMap[sprite1] != hashMap[sprite2] );
			
			hashMap.put( sprite1, "sp1" );
			hashMap.put( sprite2, "sp2" );
			
			trace( "使用中括号put赋值与get取值,是否支持非字符串作为键值:",  hashMap.get( sprite1 ) != hashMap.get(sprite2) );
			
			trace( "测试Key for关键字迭代( 不支持非字符串与Number类型的Key ):" );
			
			var key:Object
			
			for( key in hashMap )
			{
				trace( "key:", key, " value:", hashMap.get( key ) );
			}
			
			trace( "===========================" );
			
			trace( "测试value for each 关键字迭代:" );
			
			var val:Object;
			
			for each( val in hashMap )
			{
				trace( "val:", val );
			}
			 
			trace( "===========================" );
			
			trace( "测试remove:", hashMap.remove( "key" ) );
			
			trace( "测试 eachKey,  eachValue:" );
			
			hashMap.eachKey( function( k:Object ):void{ trace( "each key:",  k,  " type:", flash.utils.getQualifiedClassName( k ) ); } );
			
			trace( "===========================" );
			
			hashMap.eachValue( function( v:Object ):void{ trace( "each value:",  v,  " type:", flash.utils.getQualifiedClassName( v ) ); } );
			
			trace( "===========================" );
			
			var dic:Dictionary = new Dictionary();
			
			hashMap.put( null, "gogo" );
			
			hashMap.put( undefined, "ddd" );
			
			trace( "测试toString():", hashMap.toString() );
			
		}
	}
}